<template>
  <div class="app-container">
    <el-form
      ref="form"
      :model="form"
      label-width="80px"
      style="background-color: #ffffff"
    >
      <el-form-item label="硬件信息">
        <el-col :span="11">
          <el-input v-model="form.machineMac" size="small"></el-input>
        </el-col>
      </el-form-item>

      <el-form-item label="起始时间">
        <el-col :span="11">
          <el-date-picker
            v-model="form.licenseStartDate"
            type="date"
            placeholder="选择日期"
            style="width: 100%"
          ></el-date-picker>
        </el-col>
      </el-form-item>
      <el-form-item label="结束时间">
        <el-col :span="11">
          <el-date-picker
            v-model="form.licenseEndDate"
            type="date"
            placeholder="选择日期"
            style="width: 100%"
          ></el-date-picker>
        </el-col>
      </el-form-item>

      <el-form-item label="产品模块">
        <el-select v-model="form.licenseName" placeholder="产品模块">
          <el-option
            v-for="(item, index) in form.modules"
            :key="index"
            :label="item.moduleName"
            :value="item.moduleID"
          ></el-option>
        </el-select>
      </el-form-item>

      <el-form-item label="许可数量">
        <el-input-number
          v-model="form.licenseCount"
          :min="1"
          label="描述文字"
        ></el-input-number>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" @click="onSubmit">立即提交</el-button>
        <el-button>取消</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
  import { getAction, postAction, deleteAction, putAction } from '@/api/action'
  export default {
    name: 'LicenseGeneration',
    data() {
      return {
        form: {
          machineMac: '', //用户设备硬件MAC地址
          licenseName: '', //选中的产品模块
          modules: [
            { moduleName: '模块1', moduleID: '001' },
            { moduleName: '模块2', moduleID: '002' },
          ], //产品模块列表
          licenseStartDate: '', //授权开始时间
          licenseEndDate: '', //授权结束时间
          licenseCount: '', //许可数量
          delivery: false,
          type: [],
          resource: '',
          desc: '',
        },
        url: {
          generation: '/presoftasim/licensemanage/licenseGeneration/generation',
          moduleList: '/presoftasim/licensemanage/licenseGeneration/moduelList',
        },
      }
    },
    created() {
      this.getModuleList()
    },
    methods: {
      onSubmit() {
        postAction(this.url.generation, this.form).then((res) => {
          if (res.code == 200) {
            this.getList()
          } else {
            this.submitFail(res.message)
          }
        })
      },
      getModuleList: function () {
        getAction(this.url.moduleList, this.calParam).then((res) => {
          if (res.code == 200) {
            this.form.modules = res.data
          } else {
            this.submitFail(res.message)
          }
        })
      },
    },
  }
</script>

<style scoped></style>
